package com.czl.module_storehouse.mvp.model;

import com.czl.base.data.net.RetrofitClient;
import com.czl.module_base.bean.ListBean;
import com.czl.module_base.http.HttpResponse;
import com.czl.module_storehouse.api.ApiService;
import com.czl.module_storehouse.bean.StoreHouseBean;

import org.json.JSONObject;

import io.reactivex.Observable;

/**
 * @author by xubin,
 * @date on 2022/3/2.
 * PS: Not easy to write code, please indicate.
 */
public class StorehouseModel extends BasicDataModel {
    public Observable<HttpResponse<ListBean<StoreHouseBean>>> getManageCompanystorehouseList(String applyCompanyId) {
        JSONObject object = new JSONObject();
        try {
            object.put("userId", getUserId());
            object.put("companyId", applyCompanyId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return RetrofitClient.getInstance().create(ApiService.class).getManageCompanystorehouseList(createBody(object));
    }

    public Observable<HttpResponse<ListBean<StoreHouseBean>>> getStorehouseByUserId() {
        JSONObject object = new JSONObject();
        try {
            object.put("userId", getUserId());
            object.put("companyId", getManageCompanyId());
            object.put("roomInfo", 1);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return RetrofitClient.getInstance().create(ApiService.class).getStorehouseByUserId(createBody(object));
    }
}
